import random
import string
import sys
# from User import User
# from bank import bank

'''
print("************************")
print("*     中国工商银行       *")
print("*     账户管理系统       *")
print("*       V1.0           *")
print("************************")
print("* 1.开户                *")
print("* 2.存钱                *")
print("* 3.取钱                *")
print("* 4.转账                *")
print("* 5.查询                *")
print("* 6.BYE                *")
print("************************")

num = '1234567890'
sa = []
for i in range(8):
    sa.append(random.choice(num))
id=''.join(sa)
print(id)

user=input("请输入你的姓名")
print(user)
password=[]
bb=0
print("请输入6位数字密码并每个回车确认")
while True:
    if bb>5:
        break
    ab=input()

    if ab.isdigit():
        ab=int(ab)
        password.append(ab)
        bb = bb + 1
    else:
        print("输入违法请重新输入")
        
print(password)        



addr=[]
print("请输入你的地址")
addr.append(input("国家:"))
addr.append(input("省份:"))
addr.append(input("街道:"))
addr.append(input("门牌号:"))
print(addr)




money=int(input("请输入你的存款余额"))
print(money)

bankaddr=input("请选择你的开户银行")
print(bankaddr)
'''
class User():
    def __init__(self):
        self.name=''
        self.password=''
        self.cardId=''
        self.money=0
        self.addr=''
        self.bank1=''
class bank():
    dict1={}
    list=[]

sa = []

num = '1234567890'
addr = []
def Open():
    per1=User()
    per1.name=input("请输入您的姓名")
    per1.password=input("请输入6位数密码")
    for i in range(8):
        sa.append(random.choice(num))
    per1.cardId=''.join(sa)
    print("您的卡号为",per1.cardId)
    print("请输入你的地址")
    addr.append(input("国家:"))
    addr.append(input("省份:"))
    addr.append(input("街道:"))
    addr.append(input("门牌号:"))
    per1.money=input("请输入存款金额")
    per1.addr=addr
    per1.bank1=input("请选择您的开户银行")
    c=per1.cardId
    bank.dict1[c]=per1
    print("注册成功")



def slect():
    i=input("请输入您的账户ID:")
    if i not in bank.dict1.keys():
        print("账户不存在")
        return -1
    else:
        ps=input("请输入六位数密码")
        if ps == bank.dict1[i].password:
            print("登录成功：")
            print("当前账户：",bank.dict1[i].cardId)
            print("密码为：",bank.dict1[i].password)
            print("当前账户余额：",bank.dict1[i].money)
            print("现居住地址：",bank.dict1[i].addr)
            print("开户银行：",bank.dict1[i].bank1)
            return -1

        else:
            print("密码错误，请重新输入")
            return -1



def save():
    i = input("请输入您的账户ID:")
    if i not in bank.dict1.keys():
        print("账户不存在")
        return -1
    else:
        ps=input("请输入六位数密码")
        if ps == bank.dict1[i].password:
            print("登录成功")
            while True:
                c = input("请输入您要存款的金额")
                if c<=0:
                    print("存款金额不能为0!")
                else:
                    break
            bank.dict1[i].money += c
            print("存款成功！您的余额为：",bank.dict1[i].money)
            return -1
        else:
            print("密码错误！")
            return -1



def draw():
    i = input("请输入您的账户ID:")
    if i not in bank.dict1.keys():
        print("账户不存在")
        return -1
    else:
        ps = input("请输入六位数密码")
        if ps == bank.dict1[i].password:
            print("登录成功")
            while True:
                d = input("请输入您需要取出的金额")
                if d > bank.dict1[i].money:
                    print("余额不足,请重新输入")
                elif d<=0:
                    print("体现必须大于0")
                else:

                    break
                bank.dict1[i].money -= d
                print("取款成功，您的余额为：",bank.dict1[i].money)
                return -1
        else:
            print("密码错误")
            return -1


def trsfer():
    i = input("请输入您的账户ID:")
    if i not in bank.dict1.keys():
        print("账户不存在")
        return -1
    else:
        ps = input("请输入六位数密码")
        if ps == bank.dict1[i].password:
            print("登录成功")
            while True:
                e = input("请输入转账账户")
                if e not in bank.dict1.keys():
                    print("账户不存在")
                else:
                    while True:
                        f = input("请输入需要转账的金额")
                        if f >=bank.dict1[i].money:
                            print("余额不足，请重新输入")
                        else:
                            break
                    bank.dict1[i].money -= f
                    bank.dict1[e].money += f
                    print("转账成功，您的余额为",bank.dict1[i].money)
                    return -1
        else:
            print("密码错误")
            return -1




def main():
    while True:
        print("************************")
        print("*     中国工商银行       *")
        print("*     账户管理系统       *")
        print("*       V1.0           *")
        print("************************")
        print("* 1.开户                *")
        print("* 2.存钱                *")
        print("* 3.取钱                *")
        print("* 4.转账                *")
        print("* 5.查询                *")
        print("* 6.BYE                *")
        print("************************")
        ch=input("请选择您需要的业务！")
        if ch=="1":
            Open()
        elif ch=="2":
            save()
        elif ch=="3":
            draw()
        elif ch=="4":
            trsfer()
        elif ch=="5":
            slect()
        elif ch=="6":
            sys.exit()
        else:
            print("非法输入")
if __name__ == '__main__':
    main()



